home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / perl5 / DateTime / Locale.pm next >
Encoding:
Perl POD Document  |  2010-03-19  |  24.8 KB  |  922 lines

  1. package DateTime::Locale;
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use 5.006;
  7.  
  8. # Loading this here isn't necessary, but it makes it easier to catch
  9. # syntax errors when testing.
  10. use DateTime::Locale::Base;
  11. use DateTime::Locale::Catalog;
  12. use Params::Validate qw( validate validate_pos SCALAR );
  13.  
  14. our $VERSION = '0.45';
  15.  
  16. my %Class;
  17. my %DataForID;
  18. my %NameToID;
  19. my %NativeNameToID;
  20. my %AliasToID;
  21. my %IDToExtra;
  22.  
  23. my %LoadCache;
  24.  
  25. sub register {
  26.     my $class = shift;
  27.  
  28.     %LoadCache = ();
  29.  
  30.     if ( ref $_[0] ) {
  31.         $class->_register(%$_) foreach @_;
  32.     }
  33.     else {
  34.         $class->_register(@_);
  35.     }
  36. }
  37.  
  38. sub _register {
  39.     my $class = shift;
  40.  
  41.     my %p = validate(
  42.         @_, {
  43.             id => { type => SCALAR },
  44.  
  45.             en_language  => { type => SCALAR },
  46.             en_script    => { type => SCALAR, optional => 1 },
  47.             en_territory => { type => SCALAR, optional => 1 },
  48.             en_variant   => { type => SCALAR, optional => 1 },
  49.  
  50.             native_language  => { type => SCALAR, optional => 1 },
  51.             native_script    => { type => SCALAR, optional => 1 },
  52.             native_territory => { type => SCALAR, optional => 1 },
  53.             native_variant   => { type => SCALAR, optional => 1 },
  54.  
  55.             class   => { type => SCALAR, optional => 1 },
  56.             replace => { type => SCALAR, default  => 0 },
  57.         }
  58.     );
  59.  
  60.     my $id = $p{id};
  61.  
  62.     die "'\@' or '=' are not allowed in locale ids"
  63.         if $id =~ /[\@=]/;
  64.  
  65.     die
  66.         "You cannot replace an existing locale ('$id') unless you also specify the 'replace' parameter as true\n"
  67.         if !delete $p{replace} && exists $DataForID{$id};
  68.  
  69.     $p{native_language} = $p{en_language}
  70.         unless exists $p{native_language};
  71.  
  72.     my @en_pieces;
  73.     my @native_pieces;
  74.     foreach my $p (qw( language script territory variant )) {
  75.         push @en_pieces,     $p{"en_$p"}     if exists $p{"en_$p"};
  76.         push @native_pieces, $p{"native_$p"} if exists $p{"native_$p"};
  77.     }
  78.  
  79.     $p{en_complete_name}     = join ' ', @en_pieces;
  80.     $p{native_complete_name} = join ' ', @native_pieces;
  81.  
  82.     $DataForID{$id} = \%p;
  83.  
  84.     $NameToID{ $p{en_complete_name} }           = $id;
  85.     $NativeNameToID{ $p{native_complete_name} } = $id;
  86.  
  87.     $Class{$id} = $p{class} if defined exists $p{class};
  88. }
  89.  
  90. sub _registered_id {
  91.     shift;
  92.     my ($id) = validate_pos( @_, { type => SCALAR } );
  93.  
  94.     return 1 if $AliasToID{$id};
  95.     return 1 if $DataForID{$id};
  96.  
  97.     return 0;
  98. }
  99.  
  100. sub add_aliases {
  101.     shift;
  102.  
  103.     %LoadCache = ();
  104.  
  105.     my $aliases = ref $_[0] ? $_[0] : {@_};
  106.  
  107.     while ( my ( $alias, $id ) = each %$aliases ) {
  108.         die
  109.             "Unregistered locale '$id' cannot be used as an alias target for $alias"
  110.             unless __PACKAGE__->_registered_id($id);
  111.  
  112.         die "Can't alias an id to itself"
  113.             if $alias eq $id;
  114.  
  115.         # check for overwrite?
  116.  
  117.         my %seen = ( $alias => 1, $id => 1 );
  118.         my $copy = $id;
  119.         while ( $copy = $AliasToID{$copy} ) {
  120.             die "Creating an alias from $alias to $id would create a loop.\n"
  121.                 if $seen{$copy};
  122.  
  123.             $seen{$copy} = 1;
  124.         }
  125.  
  126.         $AliasToID{$alias} = $id;
  127.     }
  128. }
  129.  
  130. sub remove_alias {
  131.     shift;
  132.  
  133.     %LoadCache = ();
  134.  
  135.     my ($alias) = validate_pos( @_, { type => SCALAR } );
  136.  
  137.     return delete $AliasToID{$alias};
  138. }
  139.  
  140. BEGIN {
  141.     __PACKAGE__->register( DateTime::Locale::Catalog->Locales() );
  142.     __PACKAGE__->add_aliases( DateTime::Locale::Catalog->Aliases() );
  143. }
  144.  
  145. sub ids   { wantarray ? keys %DataForID : [ keys %DataForID ] }
  146. sub names { wantarray ? keys %NameToID  : [ keys %NameToID ] }
  147.  
  148. sub native_names {
  149.     wantarray ? keys %NativeNameToID : [ keys %NativeNameToID ];
  150. }
  151.  
  152. # These are hardcoded for backwards comaptibility with the
  153. # DateTime::Language code.
  154. my %OldAliases = (
  155.     'Afar'      => 'aa',
  156.     'Amharic'   => 'am_ET',
  157.     'Austrian'  => 'de_AT',
  158.     'Brazilian' => 'pt_BR',
  159.     'Czech'     => 'cs_CZ',
  160.     'Danish'    => 'da_DK',
  161.     'Dutch'     => 'nl_NL',
  162.     'English'   => 'en_US',
  163.     'French'    => 'fr_FR',
  164.  
  165.     #      'Gedeo'             => undef, # XXX
  166.     'German'            => 'de_DE',
  167.     'Italian'           => 'it_IT',
  168.     'Norwegian'         => 'no_NO',
  169.     'Oromo'             => 'om_ET',    # Maybe om_KE or plain om ?
  170.     'Portugese'         => 'pt_PT',
  171.     'Sidama'            => 'sid',
  172.     'Somali'            => 'so_SO',
  173.     'Spanish'           => 'es_ES',
  174.     'Swedish'           => 'sv_SE',
  175.     'Tigre'             => 'tig',
  176.     'TigrinyaEthiopian' => 'ti_ET',
  177.     'TigrinyaEritrean'  => 'ti_ER',
  178. );
  179.  
  180. sub load {
  181.     my $class = shift;
  182.     my ($name) = validate_pos( @_, { type => SCALAR } );
  183.  
  184.     # Support RFC 3066 language tags, which use '-' instead of '_'.
  185.     $name =~ tr/-/_/;
  186.  
  187.     my $key = $name;
  188.  
  189.     return $LoadCache{$key} if exists $LoadCache{$key};
  190.  
  191.     # Custom class registered by user
  192.     if ( $Class{$name} ) {
  193.         return $LoadCache{$key}
  194.             = $class->_load_class_from_id( $name, $Class{$name} );
  195.     }
  196.  
  197.     # special case for backwards compatibility with DT::Language
  198.     $name = $OldAliases{$name} if exists $OldAliases{$name};
  199.  
  200.     if ( exists $DataForID{$name} || exists $AliasToID{$name} ) {
  201.         return $LoadCache{$key} = $class->_load_class_from_id($name);
  202.     }
  203.  
  204.     foreach my $h ( \%NameToID, \%NativeNameToID ) {
  205.         return $LoadCache{$key} = $class->_load_class_from_id( $h->{$name} )
  206.             if exists $h->{$name};
  207.     }
  208.  
  209.     if ( my $id = $class->_guess_id($name) ) {
  210.         return $LoadCache{$key} = $class->_load_class_from_id($id);
  211.     }
  212.  
  213.     die "Invalid locale name or id: $name\n";
  214. }
  215.  
  216. sub _guess_id {
  217.     my $class = shift;
  218.     my $name  = shift;
  219.  
  220.     # Strip off charset for LC_* ids : en_GB.UTF-8 etc
  221.     $name =~ s/\..*$//;
  222.  
  223.     my ( $language, $script, $territory, $variant ) = _parse_id($name);
  224.  
  225.     my @guesses;
  226.  
  227.     if ( defined $script ) {
  228.         my $guess = join '_', lc $language, ucfirst lc $script;
  229.  
  230.         push @guesses, $guess;
  231.  
  232.         $guess .= '_' . uc $territory if defined $territory;
  233.  
  234.         # version with script comes first
  235.         unshift @guesses, $guess;
  236.     }
  237.  
  238.     if ( defined $variant ) {
  239.         push @guesses, join '_', lc $language, uc $territory, uc $variant;
  240.     }
  241.  
  242.     if ( defined $territory ) {
  243.         push @guesses, join '_', lc $language, uc $territory;
  244.     }
  245.  
  246.     push @guesses, lc $language;
  247.  
  248.     foreach my $id (@guesses) {
  249.         return $id
  250.             if exists $DataForID{$id} || exists $AliasToID{$id};
  251.     }
  252. }
  253.  
  254. sub _parse_id {
  255.     $_[0] =~ /([a-z]+)               # id
  256.               (?: _([A-Z][a-z]+) )?  # script - Title Case - optional
  257.               (?: _([A-Z]+) )?       # territory - ALL CAPS - optional
  258.               (?: _([A-Z]+) )?       # variant - ALL CAPS - optional
  259.              /x;
  260.  
  261.     return $1, $2, $3, $4;
  262. }
  263.  
  264. sub _load_class_from_id {
  265.     my $class      = shift;
  266.     my $id         = shift;
  267.     my $real_class = shift;
  268.  
  269.     # We want the first alias for which there is data, even if it has
  270.     # no corresponding .pm file.  There may be multiple levels of
  271.     # alias to go through.
  272.     my $data_id = $id;
  273.     while ( exists $AliasToID{$data_id} && !exists $DataForID{$data_id} ) {
  274.         $data_id = $AliasToID{$data_id};
  275.     }
  276.  
  277.     $real_class ||= "DateTime::Locale::$data_id";
  278.  
  279.     unless ( $real_class->can('new') ) {
  280.         eval "require $real_class";
  281.  
  282.         die $@ if $@;
  283.     }
  284.  
  285.     my $locale = $real_class->new(
  286.         %{ $DataForID{$data_id} },
  287.         id => $id,
  288.     );
  289.  
  290.     return $locale if $DateTime::Locale::InGenerator;
  291.  
  292.     if ( $locale->can('cldr_version') ) {
  293.         my $object_version  = $locale->cldr_version();
  294.         my $catalog_version = DateTime::Locale::Catalog->CLDRVersion();
  295.  
  296.         if ( $object_version ne $catalog_version ) {
  297.             warn
  298.                 "Loaded $real_class, which is from an older version ($object_version)"
  299.                 . "of the CLDR database than this installation of"
  300.                 . "DateTime::Locale ($catalog_version).\n";
  301.         }
  302.     }
  303.  
  304.     return $locale;
  305. }
  306.  
  307. 1;
  308.  
  309. __END__
  310.  
  311. =pod
  312.  
  313. =encoding utf8
  314.  
  315. =head1 NAME
  316.  
  317. DateTime::Locale - Localization support for DateTime.pm
  318.  
  319. =head1 SYNOPSIS
  320.  
  321.   use DateTime::Locale;
  322.  
  323.   my $loc = DateTime::Locale->load('en_GB');
  324.  
  325.   print $loc->native_locale_name(),   "\n",
  326.     $loc->datetime_format_long(), "\n";
  327.  
  328.   # but mostly just things like ...
  329.  
  330.   my $dt = DateTime->now( locale => 'fr' );
  331.   print "Aujourd'hui le mois est " . $dt->month_name(), "\n";
  332.  
  333. =head1 DESCRIPTION
  334.  
  335. DateTime::Locale is primarily a factory for the various locale
  336. subclasses. It also provides some functions for getting information on
  337. all the available locales.
  338.  
  339. If you want to know what methods are available for locale objects,
  340. then please read the C<DateTime::Locale::Base> documentation.
  341.  
  342. =head1 USAGE
  343.  
  344. This module provides the following class methods:
  345.  
  346. =head2 DateTime::Locale->load( $locale_id | $locale_name | $alias )
  347.  
  348. Returns the locale object for the specified locale id, name, or alias
  349. - see the C<DateTime::Locale::Catalog> documentation for a list of
  350. built in names and ids. The name provided may be either the English
  351. or native name.
  352.  
  353. If the requested locale is not found, a fallback search takes place to
  354. find a suitable replacement.
  355.  
  356. The fallback search order is:
  357.  
  358.   {language}_{script}_{territory}
  359.   {language}_{script}
  360.   {language}_{territory}_{variant}
  361.   {language}_{territory}
  362.   {language}
  363.  
  364. Eg. For locale C<es_XX_UNKNOWN> the fallback search would be:
  365.  
  366.   es_XX_UNKNOWN   # Fails - no such locale
  367.   es_XX           # Fails - no such locale
  368.   es              # Found - the es locale is returned as the
  369.                   # closest match to the requested id
  370.  
  371. Eg. For locale C<es_Latn_XX> the fallback search would be:
  372.  
  373.   es_Latn_XX      # Fails - no such locale
  374.   es_Latn         # Fails - no such locale
  375.   es_XX           # Fails - no such locale
  376.   es              # Found - the es locale is returned as the
  377.                   # closest match to the requested id
  378.  
  379. If no suitable replacement is found, then an exception is thrown.
  380.  
  381. Please note that if you provide an B<id> to this method, then the
  382. returned locale object's C<id()> method will B<always> return the
  383. value you gave, even if that value was an alias to some other id.
  384.  
  385. This is done for forwards compatibility, in case something that is
  386. currently an alias becomes a unique locale in the future.
  387.  
  388. This means that the value of C<< $locale->id() >> and the object's
  389. class may not match.
  390.  
  391. The loaded locale is cached, so that B<locale objects may be
  392. singletons>. Calling C<< DateTime::Locale->register() >>, C<<
  393. DateTime::Locale->add_aliases() >>, or C<<
  394. DateTime::Locale->remove_alias() >> clears the cache.
  395.  
  396. =head2 DateTime::Locale->ids()
  397.  
  398.   my @ids = DateTime::Locale->ids();
  399.   my $ids = DateTime::Locale->ids();
  400.  
  401. Returns an unsorted list of the available locale ids, or an array
  402. reference if called in a scalar context. This list does not include
  403. aliases.
  404.  
  405. =head2 DateTime::Locale->names()
  406.  
  407.   my @names = DateTime::Locale->names();
  408.   my $names = DateTime::Locale->names();
  409.  
  410. Returns an unsorted list of the available locale names in English, or
  411. an array reference if called in a scalar context.
  412.  
  413. =head2 DateTime::Locale->native_names()
  414.  
  415.   my @names = DateTime::Locale->native_names();
  416.   my $names = DateTime::Locale->native_names();
  417.  
  418. Returns an unsorted list of the available locale names in their native
  419. language, or an array reference if called in a scalar context. All
  420. native names are utf8 encoded.
  421.  
  422. B<NB>: Some locales are only partially translated, so their native locale
  423. names may still contain some English.
  424.  
  425. =head2 DateTime::Locale->add_aliases ( $alias1 => $id1, $alias2 => $id2, ... )
  426.  
  427. Adds an alias to an existing locale id. This allows a locale to be
  428. loaded by its alias rather than id or name. Multiple aliases are
  429. allowed.
  430.  
  431. If the passed locale id is neither registered nor listed in
  432. L<DateTime::Local::Catalog>'s list of ids, an exception is thrown.
  433.  
  434.  DateTime::Locale->add_aliases( LastResort => 'es_ES' );
  435.  
  436.  # Equivalent to DateTime::Locale->load('es_ES');
  437.  DateTime::Locale->load('LastResort');
  438.  
  439. You can also pass a hash reference to this method.
  440.  
  441.  DateTime::Locale->add_aliases( { Default     => 'en_GB',
  442.                                   Alternative => 'en_US',
  443.                                   LastResort  => 'es_ES' } );
  444.  
  445. =head2 DateTime::Locale->remove_alias( $alias )
  446.  
  447. Removes a locale id alias, and returns true if the specified alias
  448. actually existed.
  449.  
  450.  DateTime::Locale->add_aliases( LastResort => 'es_ES' );
  451.  
  452.  # Equivalent to DateTime::Locale->load('es_ES');
  453.  DateTime::Locale->load('LastResort');
  454.  
  455.  DateTime::Locale->remove_alias('LastResort');
  456.  
  457.  # Throws an exception, 'LastResort' no longer exists
  458.  DateTime::Locale->load('LastResort');
  459.  
  460. =head2 DateTime::Locale->register( { ... }, { ... } )
  461.  
  462. This method allows you to register custom locales with the module. A
  463. single locale is specified as a hash, and you may register multiple
  464. locales at once by passing an array of hash references.
  465.  
  466. Until registered, custom locales cannot be instantiated via C<load()>
  467. and will not be returned by querying methods such as C<ids()> or
  468. C<names()>.
  469.  
  470.  register( id           => $locale_id,
  471.            en_language  => ..., # something like 'English' or 'Afar',
  472.  
  473.            # All other keys are optional. These are:
  474.            en_script    => ...,
  475.            en_territory => ...,
  476.            en_variant   => ...,
  477.  
  478.            native_language  => ...,
  479.            native_sript     => ...,
  480.            native_territory => ...,
  481.            native_variant   => ...,
  482.  
  483.            # Optional - defaults to DateTime::Locale::$locale_id
  484.            class   => $class_name,
  485.  
  486.            replace => $boolean
  487.          )
  488.  
  489. The locale id and English name are required, and the following formats
  490. should used wherever possible:
  491.  
  492.  id:   languageId[_script][_territoryId[_variantId]]
  493.  
  494.  Where:  languageId = Lower case ISO 639 code -
  495.          Always choose 639-1 over 639-2 where possible.
  496.  
  497.  script = Title Case ISO 15924 script code
  498.  
  499.  territoryId = Upper case ISO 3166 code -
  500.                Always choose 3166-1 over 3166-2 where possible.
  501.  
  502.  variantId = Upper case variant id -
  503.              Basically anything you want, since this is typically the
  504.              component that uniquely identifies a custom locale.
  505.  
  506. You cannot not use '@' or '=' in locale ids - these are reserved for
  507. future use. The underscore (_) is the component separator, and should
  508. not be used for any other purpose.
  509.  
  510. If the "native_*" components are supplied, they must be utf8 encoded.
  511.  
  512. If omitted, the native name is assumed to be identical to the English
  513. name.
  514.  
  515. If class is supplied, it must be the full module name of your custom
  516. locale. If omitted, the locale module is assumed to be a
  517. DateTime::Locale subclass.
  518.  
  519. Examples:
  520.  
  521.  DateTime::Locale->register
  522.      ( id           => 'en_GB_RIDAS',
  523.        en_language  => 'English',
  524.        en_territory => 'United Kingdom',
  525.        en_variant   => 'Ridas Custom Locale',
  526.      );
  527.  
  528.  # Returns instance of class DateTime::Locale::en_GB_RIDAS
  529.  my $l = DateTime::Locale->load('en_GB_RIDAS');
  530.  
  531.  DateTime::Locale->register
  532.      ( id               => 'hu_HU',
  533.        en_language      => 'Hungarian',
  534.        en_territory     => Hungary',
  535.        native_language  => 'Magyar',
  536.        native_territory => 'Magyarorsz├íg',
  537.      );
  538.  
  539.  # Returns instance of class DateTime::Locale::hu_HU
  540.  my $l = DateTime::Locale->load('hu_HU');
  541.  
  542.  DateTime::Locale->register
  543.      ( id    => 'en_GB_RIDAS',
  544.        name  => 'English United Kingdom Ridas custom locale',
  545.        class => 'Ridas::Locales::CustomGB',
  546.      );
  547.  
  548.  # Returns instance of class Ridas::Locales::CustomGB
  549.  my $l = DateTime::Locale->load('en_GB_RIDAS');
  550.  
  551. If you register a locale for an id that is already registered, the
  552. "replace" parameter must be true or an exception will be thrown.
  553.  
  554. The complete name for a registered locale is generated by joining
  555. together the language, territory, and variant components with a single
  556. space.
  557.  
  558. This means that in the first example, the complete English and native
  559. names for the locale would be "English United Kingdom Ridas Custom
  560. Locale", and in the second example the complete English name is
  561. "Hungarian Hungary", while the complete native name is "Magyar
  562. Magyarorsz├íg". The locale will be loadable by these complete names
  563. (English and native), via the C<load()> method.
  564.  
  565. =head1 ADDING CUSTOM LOCALES
  566.  
  567. These are added in one of two ways:
  568.  
  569. =over 4
  570.  
  571. =item 1.
  572.  
  573. Subclass an existing locale implementing only the changes you require.
  574.  
  575. =item 2.
  576.  
  577. Create a completely new locale as a new class.
  578.  
  579. =back
  580.  
  581. In either case the locale MUST be registered before use.
  582.  
  583. =head2 Subclassing an existing locale
  584.  
  585. The following example sublasses the United Kingdom English locale to change
  586. some the full date and time formats.
  587.  
  588.   package Ridas::Locale::en_GB_RIDAS1;
  589.  
  590.   use strict;
  591.   use DateTime::Locale::en_GB;
  592.  
  593.   use base 'DateTime::Locale::en_GB';
  594.  
  595.   sub date_format_full   { 'EEEE d MMMM y' }
  596.  
  597.   sub time_format_full   { 'HH mm zzzz' }
  598.  
  599.   1;
  600.  
  601. Now register it:
  602.  
  603.  DateTime::Locale->register
  604.      ( id    => 'en_GB_RIDAS1',
  605.  
  606.        # name, territory, and variant as described in register() documentation
  607.  
  608.        class => 'Ridas::Locale::en_GB_RIDAS1',
  609.      );
  610.  
  611. =head2 Creating a completely new locale
  612.  
  613. You are, of course, free to subclass L<DateTime::Locale::Base> if you
  614. want to, though this is not required.
  615.  
  616. Remember to register your custom locale!
  617.  
  618. Of course, you can always do the registration in the module itself,
  619. and simply load it before using it.
  620.  
  621. A completely new custom locale, one which does not subclass
  622. L<DateTime::Locale::Base>, must implement a number of methods.
  623.  
  624. The following methods can be used to get information about the
  625. locale's id and name.
  626.  
  627. =over 4
  628.  
  629. =item * $locale->id()
  630.  
  631. The complete locale id, something like "en_US".
  632.  
  633. =item * $locale->language_id()
  634.  
  635. The language portion of the id, like "en".
  636.  
  637. =item * $locale->script_id()
  638.  
  639. The script portion of the id, like "Hant".
  640.  
  641. =item * $locale->territory_id()
  642.  
  643. The territory portion of the id, like "US".
  644.  
  645. =item * $locale->variant_id()
  646.  
  647. The variant portion of the id, like "PREEURO".
  648.  
  649. =item * $locale->name()
  650.  
  651. The locale's complete name, which always includes at least a language
  652. component, plus optional territory and variant components. Something
  653. like "English United States". The value returned will always be in
  654. English.
  655.  
  656. =item * $locale->language()
  657.  
  658. =item * $locale->script()
  659.  
  660. =item * $locale->territory()
  661.  
  662. =item * $locale->variant()
  663.  
  664. The relevant component from the locale's complete name, like "English"
  665. or "United States".
  666.  
  667. =item * $locale->native_name()
  668.  
  669. The locale's complete name in localized form as a UTF-8 string.
  670.  
  671. =item * $locale->native_language()
  672.  
  673. =item * $locale->native_script()
  674.  
  675. =item * $locale->native_territory()
  676.  
  677. =item * $locale->native_variant()
  678.  
  679. The relevant component from the locale's complete native name as a
  680. UTF-8 string.
  681.  
  682. =back
  683.  
  684. The following methods all return an array reference containing the
  685. specified data.
  686.  
  687. The methods with "format" in the name should return strings that can be used a
  688. part of a string, like "the month of July". The stand alone values are for
  689. use in things like calendars, and the narrow form may not be unique (for
  690. example, in day column heading for a calendar it's okay to have "T" for both
  691. Tuesday and Thursday).
  692.  
  693. The wide name should always be the full name of thing in question. The narrow
  694. name should be just one or two characters.
  695.  
  696. =over 4
  697.  
  698. =item * $locale->month_format_wide()
  699.  
  700. =item * $locale->month_format_abbreviated()
  701.  
  702. =item * $locale->month_format_narrow()
  703.  
  704. =item * $locale->month_stand_alone_wide()
  705.  
  706. =item * $locale->month_stand_alone_abbreviated()
  707.  
  708. =item * $locale->month_stand_alone_narrow()
  709.  
  710. =item * $locale->day_format_wide()
  711.  
  712. =item * $locale->day_format_abbreviated()
  713.  
  714. =item * $locale->day_format_narrow()
  715.  
  716. =item * $locale->day_stand_alone_wide()
  717.  
  718. =item * $locale->day_stand_alone_abbreviated()
  719.  
  720. =item * $locale->day_stand_alone_narrow()
  721.  
  722. =item * $locale->quarter_format_wide()
  723.  
  724. =item * $locale->quarter_format_abbreviated()
  725.  
  726. =item * $locale->quarter_format_narrow()
  727.  
  728. =item * $locale->quarter_stand_alone_wide()
  729.  
  730. =item * $locale->quarter_stand_alone_abbreviated()
  731.  
  732. =item * $locale->quarter_stand_alone_narrow()
  733.  
  734. =item * $locale->am_pm_abbreviated()
  735.  
  736. =item * $locale->era_wide()
  737.  
  738. =item * $locale->era_abbreviated()
  739.  
  740. =item * $locale->era_narrow()
  741.  
  742. =back
  743.  
  744. The following methods return strings appropriate for the
  745. C<< DateTime->format_cldr() >> method:
  746.  
  747. =over 4
  748.  
  749. =item * $locale->date_format_full()
  750.  
  751. =item * $locale->date_format_long()
  752.  
  753. =item * $locale->date_format_medium()
  754.  
  755. =item * $locale->date_format_short()
  756.  
  757. =item * $locale->date_format_default()
  758.  
  759. =item * $locale->time_format_full()
  760.  
  761. =item * $locale->time_format_long()
  762.  
  763. =item * $locale->time_format_medium()
  764.  
  765. =item * $locale->time_format_short()
  766.  
  767. =item * $locale->time_format_default()
  768.  
  769. =item * $locale->datetime_format_full()
  770.  
  771. =item * $locale->datetime_format_long()
  772.  
  773. =item * $locale->datetime_format_medium()
  774.  
  775. =item * $locale->datetime_format_short()
  776.  
  777. =item * $locale->datetime_format_default()
  778.  
  779. =back
  780.  
  781. A locale may also offer one or more formats for displaying part of a
  782. datetime, such as the year and month, or hour and minute.
  783.  
  784. =over 4
  785.  
  786. =item * $locale->format_for($name)
  787.  
  788. These are accessed by passing a name to C<< $locale->format_for(...)  >>,
  789. where the name is a CLDR-style format specifier.
  790.  
  791. The return value is a string suitable for passing to C<< $dt->format_cldr()
  792. >>, so you can do something like this:
  793.  
  794.   print $dt->format_cldr( $dt->locale()->format_for('MMMdd') )
  795.  
  796. which for the "en" locale would print out something like "08 Jul".
  797.  
  798. Note that the localization may also include additional text specific to the
  799. locale. For example, the "MMMMd" format for the "zh" locale includes the
  800. Chinese characters for "day" (µùÑ) and month (µ£ê), so you get something like
  801. "8月23日".
  802.  
  803. =item * $locale->available_formats()
  804.  
  805. This should return a list of all the format names that could be passed
  806. to C<< $locale->format_for() >>.
  807.  
  808. =back
  809.  
  810. The following methods deal with the default format lengths:
  811.  
  812. =over 4
  813.  
  814. =item * $locale->default_date_format_length()
  815.  
  816. =item * $locale->default_time_format_length()
  817.  
  818. These methods return one of "full", "long", "medium", or "short",
  819. indicating the current default format length.
  820.  
  821. The default when an object is created is determined by the CLDR locale
  822. data.
  823.  
  824. =item * $locale->set_default_date_format_length($length)
  825.  
  826. =item * $locale->set_default_time_format_length($length)
  827.  
  828. These methods accept one of "full", "long", "medium", or "short",
  829. indicating the new default format length.
  830.  
  831. =back
  832.  
  833. There are also some miscellaneous methods locales should support:
  834.  
  835. =over 4
  836.  
  837. =item * $locale->prefers_24_hour_time()
  838.  
  839. Returns a boolean indicating whether or not the locale prefers 24-hour time.
  840.  
  841. =item * $locale->first_day_of_week()
  842.  
  843. Returns a number from 1 to 7 indicating the I<local> first day of the
  844. week, with Monday being 1 and Sunday being 7.
  845.  
  846. =back
  847.  
  848. =head1 SUPPORT
  849.  
  850. Please be aware that all locale data has been generated from the CLDR (Common
  851. Locale Data Repository) project locales data). The data is incomplete, and
  852. will contain errors in some locales.
  853.  
  854. When reporting errors in data, please check the primary data sources
  855. first, then where necessary report errors directly to the primary
  856. source via the CLDR bug report system. See
  857. http://unicode.org/cldr/filing_bug_reports.html for details.
  858.  
  859. Once these errors have been confirmed, please forward the error report
  860. and corrections to the DateTime mailing list, datetime@perl.org.
  861.  
  862. Support for this module is provided via the datetime@perl.org email
  863. list. See http://lists.perl.org/ for more details.
  864.  
  865. =head1 DONATIONS
  866.  
  867. If you'd like to thank me for the work I've done on this module,
  868. please consider making a "donation" to me via PayPal. I spend a lot of
  869. free time creating free software, and would appreciate any support
  870. you'd care to offer.
  871.  
  872. Please note that B<I am not suggesting that you must do this> in order
  873. for me to continue working on this particular software. I will
  874. continue to do so, inasmuch as I have in the past, for as long as it
  875. interests me.
  876.  
  877. Similarly, a donation made in this way will probably not make me work
  878. on this software much more, unless I get so many donations that I can
  879. consider working on free software full time, which seems unlikely at
  880. best.
  881.  
  882. To donate, log into PayPal and send money to autarch@urth.org or use
  883. the button on this page:
  884. L<http://www.urth.org/~autarch/fs-donation.html>
  885.  
  886. =head1 AUTHORS
  887.  
  888. Richard Evans <rich@ridas.com>
  889.  
  890. Dave Rolsky <autarch@urth.org>
  891.  
  892. These modules are loosely based on the DateTime::Language modules,
  893. which were in turn based on the Date::Language modules from Graham
  894. Barr's TimeDate distribution.
  895.  
  896. =head1 COPYRIGHT
  897.  
  898. Copyright (c) 2003 Richard Evans. Copyright (c) 2004-2009 David
  899. Rolsky. All rights reserved. This program is free software; you can
  900. redistribute it and/or modify it under the same terms as Perl itself.
  901.  
  902. This program is free software; you can redistribute it and/or modify
  903. it under the same terms as Perl itself.
  904.  
  905. The full text of the license can be found in the F<LICENSE> file included
  906. with this module.
  907.  
  908. The locale modules in directory F<DateTime/Locale/> have been
  909. generated from data provided by the CLDR project, see
  910. F<DateTime/Locale/LICENSE.cldr> for details on the CLDR data's
  911. license.
  912.  
  913. =head1 SEE ALSO
  914.  
  915. L<DateTime::Locale::Base>
  916.  
  917. datetime@perl.org mailing list
  918.  
  919. http://datetime.perl.org/
  920.  
  921. =cut
  922.